package personal.vivian.interf;

import personal.vivian.constants.EditMode;
import personal.vivian.logic.TemplatItem;
import personal.vivian.resover.HiddenResovler;

public class Options {
    private static NullAbleValdator nullAbleValdator=new NullAbleValdator();
    private static HiddenResovler hiddenResovler=new HiddenResovler();
    public static final RangeValidator rangeValidator=new RangeValidator();
    public static Option nullable(boolean nullable){
        return itemBuilder -> {
            TemplatItem item=itemBuilder.getItem();
            item.setNullable(nullable);
            item.getDataValdators().add(nullAbleValdator);
        };
    }
    public static Option notNull(){
        return nullable(false);
    }
    public static Option editMode(EditMode editMode){
        return itemBuilder -> {
            TemplatItem item=itemBuilder.getItem();
            item.setEditMode(editMode);
            item.getResovlers().add(hiddenResovler);
        };
    }
    public static Option hiddenField(){
        return itemBuilder -> {
            TemplatItem item=itemBuilder.getItem();
            item.getDataTemplate().setHiddenItem(item);
        };
    }

    public static Option val(){
        return itemBuilder -> {
            TemplatItem item=itemBuilder.getItem();
            item.getDataValdators().add(rangeValidator);
        };
    }
}
